/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ca.trader.sale;

/**
 * Categories of sales.  Each Category has a name, extracted via the getName method
 * @author Ahsan
 */
public enum SaleCategoryEnum
{
	 /**
	  * The category for clothing merchandise.
	  */
	 CLOTHING("Clothing"),
	 /**
	  * The category for Computer merchandise
	  */
	 COMPUTERS("Computers"),
	 /**
	  * The category for Home appliances merchandise
	  */
	 HOME_APPLIANCES("Home Appliances"),
	 /**
	  * The category for Vehicles
	  */
	 VEHICLES("Vehicles"),
	 /**
	  * The category for Electronics
	  */
	 ELECTRONICS("Electronics"),
	 /**
	  * The category for Collectibles
	  */
	 COLLECTIBLES("Collectibles"),
	 /**
	  * The category for Computer Accessories
	  */
	 COMPUTER_ACCESSORIES("Computer Accessories"),
	 /**
	  * The category for Furniture
	  */
	 FURNITURE("Furniture"),
	 /**
	  * The category for Video Games
	  */
	 VIDEO_GAMES("Video Games"),
	 /**
	  * The category for Pets
	  */
	 PETS("Pets"),
	 /**
	  * The category for Crockery
	  */
	 KITCHEN("Crockery");
	 
	 // Name of the category
	 private String stringName;
     
	 /**
	  * Initiates the category with a name
	  * @param stringName the name of the category
	  */
	 SaleCategoryEnum(String stringName)
	 {
		  this.stringName = stringName;
	 }

      /**
	  * Gets the name of the category
	  * @return name of the category
	  */
	 public String getName()
	 {
		  return this.stringName;
	 }
	 
	 /**
	  * Same as getName method
	  * @return name of the category
	  */
	 @Override
	 public String toString()
	 {
		  return this.stringName;
	 }
	 
	 /**
	  * Given the name of the category, returns a SalesCategoryEnum object with the name <i>categoryName</i>.  Returns null if no
	  * SaleCategoryEnum object exists with the matching name
	  * @param categoryName the name of the category
	  * @return the SaleCategoryEnum object with the matching name
	  */
	 public static SaleCategoryEnum getSaleCategoryByName (String categoryName)
	 {
		  
		  for (SaleCategoryEnum category:SaleCategoryEnum.values())
		  {
			   if (category.getName().equals(categoryName))
			   {
				    return category;
			   }
		  }
		  
		  return null;
	 }

	 /**
	  * Returns true if a category exists with the name <i>categoryName</i>.  False otherwise
	  * @param categoryName the name of the category
	  * @return true if a category exists with the name <i>categoryName</i>.  False otherwise
	  */
	 public static boolean containsCategory (String categoryName)
	 {
		  return getSaleCategoryByName (categoryName) != null;
	 }
}
